App({
  globalData: {
    // 存储扫描的文档图片
    scanImages: [],
    // 当前文档标题
    currentDocTitle: '未命名文档',
    // 用户信息
    userInfo: null
  },
  onLaunch: function() {
    // 检查相机、相册权限
    this.checkPermissions();
  },
  
  checkPermissions: function() {
    wx.getSetting({
      success: res => {
        if (!res.authSetting['scope.camera']) {
          console.log('未获取相机权限');
        }
        if (!res.authSetting['scope.writePhotosAlbum']) {
          console.log('未获取保存到相册权限');
        }
      }
    });
  },
  
  // 清空当前扫描的图片
  clearScanImages: function() {
    this.globalData.scanImages = [];
  },
  
  // 添加扫描图片
  addScanImage: function(imagePath) {
    this.globalData.scanImages.push(imagePath);
  },
  
  // 删除指定索引的扫描图片
  removeScanImage: function(index) {
    if (index >= 0 && index < this.globalData.scanImages.length) {
      this.globalData.scanImages.splice(index, 1);
      return true;
    }
    return false;
  }
})